<%
    var obj={pageTitle:"用户列表"}
%>
{{include "../layout_header.html"}}
<div class=" container-fluid">
    <div class=" page-header">
        <h2 class=" text-center text-primary">用户列表</h2>
    </div>
    <form class=" form-inline" style="margin: 10px 0" action="/customerInfo/list" method="GET">
        <input type="hidden" name="pageIndex" value="1">
        <div class=" form-group">
            <label for="" class=" ">用户名：</label>
            <input type="text" name="customername" placeholder="用户名称查询" class=" form-control">
        </div>
        <div class=" form-group">
            <label for="" class=" ">用户昵称：</label>
            <input type="text" name="customernickname" class=" form-control">
        </div>
        <div class=" form-group">
            <label for="" class=" ">用户性别：</label>
            <select name="customersex" class="form-control">
                <option value="">-请选择-</option>
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
        </div>
        <div class=" form-group">
            <label for="" class=" ">用户状态：</label>
            <select name="customerstatus" class="form-control">
                <option value="">-请选择-</option>
                <option value="0">启用</option>
                <option value="1">禁用</option>
            </select>
        </div>
            
        <div class=" form-group">
            <!-- submit提交表单 -->
            <button type="submit" class=" btn btn-primary">
                <span class=" glyphicon glyphicon-search"></span>查询
            </button>
        </div>
    </form>

    <div class=" btn-group">
        <a href="/customerInfo/addCustomerInfo" class=" btn btn-primary">
            <span class=" glyphicon glyphicon-plus"></span>新增
        </a>
        <button type="button" class=" btn btn-warning btn-edit">
            <span class=" glyphicon glyphicon-pencil"></span>编辑
        </button>
        <button type="button" class=" btn btn-danger btn-delete">
            <span class=" glyphicon glyphicon-trash"></span>删除
        </button>
        <button type="button" class=" btn btn-info" onclick="window.open('/customerInfo/exportToExcel'+location.search)">
            <span class=" glyphicon glyphicon-export"></span>导出为EXCEL
        </button>
    </div>
    <div class=" table-responsive">
        <table class=" table table-hover table-striped table-bordered table-vertical-center">
            <tr>
                <th>
                    <label for="ckAll">
                        <input type="checkbox" id="ckAll" data-toggle="ckAll" data-target="[name='ck']">全选
                    </label>
                </th>
                <th>用户账号</th>
                <th>用户昵称</th>
                <th>用户性别</th>
                <th>用户手机</th>
                <th>用户邮箱</th>
                <th>用户头像</th>
                <th>用户状态</th>
                <th>操作</th>
            </tr>

            {{each customerInfoList item index}}
            
            <tr>
                <td>
                    <input type="checkbox" name="ck" value="{{item.customerid}}">
                </td>
                <td>{{item.customername}}</td>
                <td>{{item.customernickname}}</td>
                <td>{{item.customersex}}</td>
                <td>{{item.customertel}}</td>
                <td>{{item.customermail}}
                    <a href="/customerInfo/sendMail/{{item.customermail}}" class="label label-info">
                        <span class=" glyphicon glyphicon-send"></span>    发送邮件
                    </a>
                </td>
                <td>
                    <img class="customerphotopreview" src="{{item.customerphoto}}" alt="用户头像"  style="height: 40px;">
                </td>
                <td>
                    <label class="label {{item.customerstatus==0?'label-danger':'label-success'}}">
                        {{item.customerstatus==0?"禁用":"正常"}}
                    </label>
                </td>
                <td>
                    <a href="/customerInfo/editCustomerInfo/{{item.customerid}}" class="label label-warning">
                        <span class=" glyphicon glyphicon-pencil"></span>编辑
                    </a>
                </td>
            </tr>
            {{/each}}
        </table>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $(".customerphotopreview").click(function () {
            //先拿到当前图片的地址
            imgSrc = $(this).attr("src");
            //调用插件的方法
            layer.photos({
                photos: {
                    data: [{
                        src: imgSrc
                    }]
                }
                
            });
        });
        $(".btn-delete").click(function(){
            var cks=$("[name='ck']:checked");
            if(cks.length==0){
                layer.alert("请选择你要删除的元素");
            }
            else{
                var cksValue=[];
                cks.each(function(index,ele){
                    cksValue.push(ele.value);
                });
                $.get("/goodsInfo/deleteGoodsInfo",{
                    cksValue:JSON.stringify(cksValue)
                },function(data){
                    if(data==true){
                        layer.alert("删除成功",function(index){
                            layer.close(index);
                            location.reload();
                        })
                    }
                    else{
                        layer.alert("删除失败");
                    }
                })
            }
        })
    })
</script>
{{include "../layout_pagination.html"}}


